package com.winiex.qqweibospider;

import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.Mongo;
import com.mongodb.util.JSON;

public class MongoDbManager {

	public void storeWeibo(String weibo) {

		try {
			DBObject dbObject = (DBObject) JSON.parse(weibo);

			Mongo mongo = new Mongo();
			DB db = mongo.getDB("weibo");
			DBCollection coll = db.getCollection("weibo_data");
			
			coll.insert(dbObject);
			
			DBCursor cursor = coll.find();
			
			while (cursor.hasNext()) {
				System.out.println(cursor.next());
			}
			System.out.println("DONE--");
			
		} catch (Exception e) {
		}

	}

}
